import request, { instance } from 'utils/request';

export interface LoginRequestBody {
  username: string;
  password: string;
  captchaCode?: string;
  captchaToken?: string;
}

export interface LoginResponseBody {
  token: string;
}

export const loginByJson = async (data: LoginRequestBody) => {
  // 后端期望 JSON 提交
  const res = await request.post<LoginResponseBody>('/auth/login', data, {
    headers: { 'Content-Type': 'application/json' },
  });
  return res;
};

export const logoutApi = async () => {
  // 后端从 Authorization Bearer 中解析 token
  return request.post<string>('/auth/logout', {});
};


